<?php

namespace common\modules\article\models;

use common\behaviors\TimestampBehavior;
use common\components\ActiveRecord;
use Yii;
use yii\db\Expression;

/**
 * This is the model class for table "{{%article_site}}".
 *
 * @property integer $id
 * @property string $name
 * @property string $domain
 * @property string $description
 * @property integer $status
 * @property integer $created_at
 * @property integer $updated_at
 * @property integer $created_by
 * @property integer $updated_by
 */
class Site extends ActiveRecord
{

    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%article_site}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['status', 'created_by', 'updated_by'], 'integer'],
            [['name'], 'string', 'max' => 100],
            [['description'], 'safe'],
            [['domain'], 'string', 'max' => 255]
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app/article', 'ID'),
            'name' => Yii::t('app/article', 'Name'),
            'domain' => Yii::t('app/article', 'Domain'),
            'description' => Yii::t('app/article', 'Description'),
            'status' => Yii::t('app/article', 'Status'),
            'created_at' => Yii::t('app/article', 'Created At'),
            'updated_at' => Yii::t('app/article', 'Updated At'),
            'created_by' => Yii::t('app/article', 'Created By'),
            'updated_by' => Yii::t('app/article', 'Updated By'),
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function behaviors()
    {
        $behaviors = parent::behaviors();

        $behaviors[] = [
            'class' => TimestampBehavior::className(),
            'createdAtAttribute' => 'created_at',
            'updatedAtAttribute' => 'updated_at',
            'value' => new Expression('NOW()'),
        ];
        
        return $behaviors;
    }
}
